﻿<UserControl x:Class="YouTubePlaylist.Views.PlaylistsSearchCtrl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:SharedLibrary="clr-namespace:Radovici.SharedLibrary;assembly=RadoviciSharedLibrary"
    xmlns:Ctrls="clr-namespace:Radovici.Ctrls;assembly=RadoviciCtrls"
    xmlns:Data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:Views="clr-namespace:YouTubePlaylist.Views"
    xmlns:ContentControls="clr-namespace:Radovici.Ctrls.ContentControls;assembly=RadoviciCtrls"
    xmlns:Hacks="clr-namespace:Radovici.Ctrls.Hacks;assembly=RadoviciCtrls">
    <UserControl.Resources>
        <SharedLibrary:BooleanToVisibilityConverter x:Key="ToVisibilityConverter" />
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,4">
            <TextBlock Text="Find Playlist:" Margin="0,0,4,0" VerticalAlignment="Center"/>
            <TextBox x:Name="SearchString" MinWidth="200" VerticalAlignment="Center" TextChanged="OnSearchPlaylistChanged"/>
        </StackPanel>
        <Grid Grid.Row="1">
            <Hacks:DataGridPlus ItemsSource="{Binding PlaylistsModel.Playlists}" Visibility="{Binding PlaylistsModel.HasPlaylists, Converter={StaticResource ToVisibilityConverter}}"
                                IsReadOnly="True" AutoGenerateColumns="False" SelectionChanged="OnPlaylistSelectionChanged"
                                MouseLeftButtonUp="OnMouseLeftButtonUp" MouseDoubleClicked="OnDoubleClicked">
                <Data:DataGrid.Columns>
                    <Data:DataGridTemplateColumn Header="Name">
                        <Data:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <ContentControls:Dropable>
                                    <TextBlock Text="{Binding Name}"/>
                                </ContentControls:Dropable>
                            </DataTemplate>
                        </Data:DataGridTemplateColumn.CellTemplate>
                    </Data:DataGridTemplateColumn>
                    <Data:DataGridTextColumn Binding="{Binding Tracks.Count}"/>
                </Data:DataGrid.Columns>
            </Hacks:DataGridPlus>
        </Grid>
        <Views:PlaylistOptionsCtrl x:Name="Options" Grid.Row="2" Margin="0,4,0,0"/>
    </Grid>
</UserControl>
